from distutils.core import setup
import py2exe
import os
import glob
from py2exe.build_exe import py2exe as build_exe

class MediaCollector(build_exe):
    def copy_extensions(self, extensions):
#        super(MediaCollector, self)
        build_exe.copy_extensions(self, extensions)

        # Create the media subdir where the
        # Python files are collected.
        media = os.path.join('..', 'data')
        full = os.path.join(self.collect_dir, media)
        if not os.path.exists(full):
            self.mkpath(full)

        # Copy the media files to the collection dir.
        # Also add the copied file to the list of compiled
        # files so it will be included in zipfile.
        for f in glob.glob(os.path.join('..','data/*')):
            name = os.path.basename(f)
            self.copy_file(f, os.path.join(full, name))
            self.compiled_files.append(os.path.join(media, name))


py2exe_options = {
            'cmdclass': {'py2exe': MediaCollector}
            #'bundle_files':1
                # [...] Other py2exe options here.
                }
setup(windows= [{'script':'run_game.py', 'icon_resources':[(0, 'skellington.ico')]}], **py2exe_options)

